package com.mt.operation.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.dubbo.config.annotation.Service;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.mt.common.PagerInfo;
import com.mt.common.ServiceResult;
import com.mt.common.constants.BaseErrorConstants;
import com.mt.operation.api.service.IArticleReviewLogService;
import com.mt.operation.entity.ArticleReviewLogEntity;
import com.mt.operation.service.model.ArticleReviewLogServiceModel;

@Service
public class ArticleReviewLogServiceImpl implements IArticleReviewLogService {

    private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(ArticleReviewLogServiceImpl.class);

    @Autowired
    private ArticleReviewLogServiceModel articleReviewLogServiceModel;

    public ServiceResult<ArticleReviewLogEntity> findInfo(Map<String, Object> params) {
        // 查询用户信息
        ServiceResult<ArticleReviewLogEntity> result = null;
        // 该参数标识前段是否需要权限数据
        try {
            result = articleReviewLogServiceModel.selectInfo(params);
        } catch (Exception e) {
            LOGGER.error("[ArticleReviewLogServiceImpl][findInfo]：query findInfo occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "查询详情错误");
        }
        return result;
    }

    public ServiceResult<Integer> findCount(Map<String, Object> params) {
        // 查询用户信息
        ServiceResult<Integer> result = null;
        // 该参数标识前段是否需要权限数据
        try {
            result = articleReviewLogServiceModel.selectCount(params);
        } catch (Exception e) {
            LOGGER.error("[ArticleReviewLogServiceImpl][findCount]：query findInfo occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "查询详情错误");
        }
        return result;
    }

    public ServiceResult<List<ArticleReviewLogEntity>> findList(Map<String, Object> params, PagerInfo<?> pagerInfo) {
        ServiceResult<List<ArticleReviewLogEntity>> result = new ServiceResult<List<ArticleReviewLogEntity>>();
        try {
            result = articleReviewLogServiceModel.selectList(params, pagerInfo);
        } catch (Exception e) {
            LOGGER.error("[ArticleReviewLogServiceImpl][findList]：query findList occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "查询列表错误");
        }

        return result;
    }

    public ServiceResult<Integer> doInsert(ArticleReviewLogEntity articleReviewLogEntity) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            result = articleReviewLogServiceModel.insert(articleReviewLogEntity);
        } catch (Exception e) {
            LOGGER.error("[ArticleReviewLogServiceImpl][doInsert]：query doInsert occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "创建信息错误");
        }
        return result;
    }

    public ServiceResult<Integer> doUpdateRelate(ArticleReviewLogEntity articleReviewLogEntity) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            result = articleReviewLogServiceModel.updateRelate(articleReviewLogEntity);
        } catch (Exception e) {
            LOGGER.error("[ArticleReviewLogServiceImpl][doUpdate]：query doUpdate occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "编辑信息错误");
        }
        return result;
    }

    public ServiceResult<Integer> doDeleteById(Integer reviewLogId) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            result = articleReviewLogServiceModel.deleteByPrimaryKey(reviewLogId);
        } catch (Exception e) {
            LOGGER.error("[ArticleReviewLogServiceImpl][doDeleteById]：query doDeleteById occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "删除信息错误");
        }
        return result;
    }

    public ServiceResult<Integer> doUpdate(ArticleReviewLogEntity articleReviewLogEntity) {
        ServiceResult<Integer> result = new ServiceResult<Integer>();
        try {
            result = articleReviewLogServiceModel.updateByPrimaryKeySelective(articleReviewLogEntity);
        } catch (Exception e) {
            LOGGER.error("[ArticleReviewLogServiceImpl][doUpdate]：query doUpdate occur exception", e);
            result.setError(BaseErrorConstants.ERROR_CODE_SERVICE_CONTROLLER, "更新信息错误.");
        }
        return result;
    }

}
